#!/usr/bin/python3
# -*- coding: utf-8 -*-

# @Time    : 2018/11/8 16:08
# @Author  : chester7cheng
# @Email   : 346835646@qq.com
# @File    : Iteration.py
# @Software: PyCharm
from collections import Iterable
from typing import Iterator

print('----------------------------------------------')
print(isinstance([], Iterable))
print(isinstance({}, Iterable))
print(isinstance('', Iterable))
print(isinstance((x for x in range(10)), Iterable))
print(isinstance(100, Iterable))
print('----------------------------------------------')
print(isinstance([], Iterator))
print(isinstance({}, Iterator))
print(isinstance('', Iterator))
print(isinstance((x for x in range(10)), Iterator))
print(isinstance(100, Iterator))
print('----------------------------------------------')
print(isinstance(iter([]), Iterator))
print(isinstance(iter({}), Iterator))
print(isinstance(iter(''), Iterator))
# print(isinstance((x for x in range(10)), Iterator))
# print(isinstance(iter(100), Iterator))

d = {'a': 1, 'b': 2, 'c': 3}

print(d)

for key in d:
    print(key)

for value in d.values():
    print(value)

print(isinstance('abc', Iterable))


def find_max_min(param):
    if len(param) == 0:
        return None, None
    max_item = min_item = param[0]
    for item in param:
        if max_item < item:
            max_item = item
        if min_item > item:
            min_item = item
    return min_item, max_item


print(find_max_min([1, 3, 5, 7, 9, 2, 4, 5, -1]))
if find_max_min([]) != (None, None):
    print('测试失败!')
elif find_max_min([7]) != (7, 7):
    print('测试失败!')
elif find_max_min([7, 1]) != (1, 7):
    print('测试失败!')
elif find_max_min([7, 1, 3, 9, 5]) != (1, 9):
    print('测试失败!')
else:
    print('测试成功!')







